/**   
 * @Title: LotteryRecordDetailFootballCommunicater.java 
 * @Package: com.esun.cheetah.biz.personal.lotteryrecord.LotteryRecordDetailFootballCommunicater 
 * @Description: (竞彩足球购彩详情接口) 
 * @author 孔祥攀 <br/>
 * @date 2012-4-22 下午2:05:35 
 * Copyright (C) 2011 Shenzhen E-sun Sky Net Technology Co.,ltd.
 */
package com.esun.cheetah.biz.personal.lotteryrecord;

import java.util.ArrayList;
import java.util.HashMap;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.os.Handler;

import com.esun.cheetah.biz.personal.personalinfo.UserInfo;
import com.esun.cheetah.config.BizCode;
import com.esun.cheetah.config.Key;
import com.esun.cheetah.model.personal.LotteryRecordDetailFootballInfo;
import com.esun.cheetah.model.personal.LotteryRecordDetailFootballInfoBSXQ;
import com.esun.cheetah.network.AbsInferiorityCommunicater;
import com.esun.util.log.EDebug;

/**
 * 
 * @Package com.esun.cheetah.biz.personal.lotteryrecord.
 *          LotteryRecordDetailFootballCommunicater
 * @ClassName: LotteryRecordDetailFootballCommunicater
 * @Description: TODO(竞彩足球购彩详情接口)
 * @author 孔祥攀 <br/>
 * @date 2012-4-22 下午2:05:35
 * 
 */
public class LotteryRecordDetailFootballCommunicater extends
		AbsInferiorityCommunicater {

	private String lotid;
	private String pid;
	private LotteryRecordDetailFootballInfo lotteryList;

	public LotteryRecordDetailFootballCommunicater(Handler handler,
			String lotid, String pid) {
		super(handler);
		this.lotid = lotid;
		this.pid = pid;
		lotteryList = new LotteryRecordDetailFootballInfo();
	}

	@Override
	public HashMap<String, String> comHashMap() {
		HashMap<String, String> hmJson = new HashMap<String, String>();
		hmJson.put(Key.KEY_ID, BizCode.BIZCODE_LotteryRecordDetail);
		hmJson.put(Key.KEY_LOTID, lotid);
		hmJson.put(Key.PID, pid);
		hmJson.put(Key.CK, UserInfo.getUserInfo().getCk());
		return hmJson;
	}

	/**
	 * @throws JSONException
	 * @Title: getJsonContent
	 * @Description: 解析json
	 * @param
	 * @return Object
	 * @throws
	 */
	@Override
	public void getJsonContent(String serverRes) throws JSONException {

		ArrayList<LotteryRecordDetailFootballInfoBSXQ> a = new ArrayList<LotteryRecordDetailFootballInfoBSXQ>();
		// LotteryRecordDetailFootballInfoBSXQ lotteryRecordBSXQ ;

		JSONObject jsonObject = new JSONObject(serverRes);
		if (!jsonObject.isNull(Key.KEY_DATA)) {
			JSONArray artr = jsonObject.getJSONArray(Key.KEY_DATA);
			for (int i = 0; i < artr.length(); i++) {
				JSONObject localJs = artr.optJSONObject(i);
				if (localJs != null) {
					LotteryRecordDetailFootballInfo lotteryListBean = new LotteryRecordDetailFootballInfo();
					EDebug.o("开始解析10047默认部分===》 ");
					lotteryListBean.playname = localJs.getString("playname"); //
					lotteryListBean.addtime = localJs.getString("addtime"); //
					lotteryListBean.proid = localJs.getString("proid"); //
					lotteryListBean.username = localJs.getString("username"); //
					lotteryListBean.allmoney = localJs.getString("allmoney"); //
					lotteryListBean.beishu = localJs.getString("beishu"); //
					lotteryListBean.ggtype = localJs.getString("ggtype"); //
					lotteryListBean.onemoney = localJs.getString("onemoney"); //
					lotteryListBean.issuc = localJs.getString("issuc"); //
					lotteryListBean.ishm = localJs.getString("ishm"); //
					lotteryListBean.isjprizesuc = localJs
							.getString("isjprizesuc"); //
					lotteryListBean.isprizesuc = localJs
							.getString("isprizesuc"); //
					lotteryListBean.baodimoney = localJs
							.getString("baodimoney"); //
					lotteryListBean.maingetmoney = localJs
							.getString("maingetmoney"); //
					lotteryListBean.renqi = localJs.getString("renqi"); //
					lotteryListBean.playid = localJs.getString("playid"); //
					lotteryListBean.ggtypename = localJs
							.getString("ggtypename"); //
					lotteryListBean.getmoney = localJs.getString("getmoney"); //
					lotteryListBean.anumber = localJs.getString("anumber"); //

					JSONObject jobj = jsonObject.optJSONObject("info");

					EDebug.o("开始解析10047原10083部分===》 ");
					lotteryListBean.balance = jobj.getString("balance");
					EDebug.o("余额===>" + lotteryListBean.balance);
					lotteryListBean.jznum = jobj.getString("jznum");
					EDebug.o("金钻===>" + lotteryListBean.jznum);
					lotteryListBean.yznum = jobj.getString("yznum");
					EDebug.o("银钻===>" + lotteryListBean.yznum);
					lotteryListBean.jxnum = jobj.getString("jxnum");
					EDebug.o("金星===>" + lotteryListBean.jxnum);
					lotteryListBean.yxnum = jobj.getString("yxnum");
					EDebug.o("银星===>" + lotteryListBean.yxnum);
					// lotteryListBean.lotname = jobj.getString("lotname");
					// EDebug.o("姓名===>" + lotteryListBean.lotname);
					lotteryListBean.prizecount = jobj.getString("prizecount");
					EDebug.o("中奖次数===>" + lotteryListBean.prizecount);
					lotteryListBean.prizemoney = jobj.getString("prizemoney");
					EDebug.o("总中奖金额===>" + lotteryListBean.prizemoney);

					JSONArray teamArr = localJs.getJSONArray("touzhuInfo");

					for (int j = 0; j < teamArr.length(); j++) {
						LotteryRecordDetailFootballInfoBSXQ lotteryRecordBSXQ = new LotteryRecordDetailFootballInfoBSXQ();
						JSONObject singleTeam = teamArr.optJSONObject(j);
						EDebug.o("开始解析10047方案详情部分===》 ");
						lotteryRecordBSXQ.matchnum = singleTeam
								.getString("matchnum");
						lotteryRecordBSXQ.homesxname = singleTeam
								.getString("homesxname");
						lotteryRecordBSXQ.awaysxname = singleTeam
								.getString("awaysxname");
						lotteryRecordBSXQ.rangqiu = singleTeam
								.getString("rangqiu");
						lotteryRecordBSXQ.score = singleTeam.getString("score");
						lotteryRecordBSXQ.result = singleTeam
								.getString("result");
						lotteryRecordBSXQ.peilv = singleTeam.getString("peilv");
						lotteryRecordBSXQ.isdanma = singleTeam
								.getString("isdanma");
						lotteryRecordBSXQ.spf = singleTeam.getString("spf");
						a.add(lotteryRecordBSXQ);
					}

					lotteryListBean.teamArr = a;

					lotteryList = lotteryListBean;

				}

			}
		}

	}

	public LotteryRecordDetailFootballInfo getLotteryList() {
		return lotteryList;
	}

	public void setLotteryList(LotteryRecordDetailFootballInfo lotteryList) {
		this.lotteryList = lotteryList;
	}
}